<script setup lang="ts">
import { postUserCashApproveListAPI } from '@/api/account'
import { useMemberStore } from '@/stores'
import type { CashApproveItem } from '@/types/member'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import NoList from '@/components/NoList.vue'

const memberStore = useMemberStore()

// 获取提现列表数据
const cashApproveList = ref<CashApproveItem[]>([])
const postUserCashApproveList = async () => {
  if (memberStore.profile.userId) {
    const res = await postUserCashApproveListAPI(memberStore.profile.userId)
    cashApproveList.value = res.data
  }
}

onLoad(() => {
  postUserCashApproveList()
})
</script>
<template>
  <view class="viewport">
    <view class="list" v-if="cashApproveList.length>0">
      <uni-list-item
        title="提现"
        :note="'日期：' + item.createTime"
        thumb="/static/images/money.png"
        :avatar-circle="true"
        v-for="item in cashApproveList"
        :key="item.id"
      >
        <template v-slot:footer>
          <view class="chat-custom-right">
            <text class="chat-custom-text minus">- {{ Number(item.cashPrice).toFixed(2) }}</text>
            <uni-tag
              :text="
                item.status == '0'
                  ? '过期'
                  : item.status == '1'
                  ? '待审核'
                  : item.status == '2'
                  ? '审核通过'
                  : '审核不通过'
              "
              type="success"
              inverted
            />
          </view>
        </template>
      </uni-list-item>
    </view>
    <no-list v-else />
  </view>
</template>

<style lang="scss">

.chat-custom-right {
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
}

.chat-custom-text {
  font-size: 14px;
}

.minus {
  margin-bottom: 5px;
}
</style>
